<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>googleapiclient.http.HttpRequest</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="googleapiclient-module.html">Package&nbsp;googleapiclient</a> ::
        <a href="googleapiclient.http-module.html">Module&nbsp;http</a> ::
        Class&nbsp;HttpRequest
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="googleapiclient.http.HttpRequest-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class HttpRequest</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_googleap_22" name="uml_class_diagram_for_googleap_22">
<area shape="rect" id="node1_6" href="googleapiclient.http.HttpRequest-class.html#__init__" title="Constructor for an HttpRequest." alt="" coords="17,39,677,59"/>
<area shape="rect" id="node1_7" href="googleapiclient.http.HttpRequest-class.html#execute" title="Execute the request." alt="" coords="17,59,677,79"/>
<area shape="rect" id="node1_8" href="googleapiclient.http.HttpRequest-class.html#add_response_callback" title="add_response_headers_callback" alt="" coords="17,79,677,99"/>
<area shape="rect" id="node1_9" href="googleapiclient.http.HttpRequest-class.html#next_chunk" title="Execute the next step of a resumable upload." alt="" coords="17,99,677,119"/>
<area shape="rect" id="node1_10" href="googleapiclient.http.HttpRequest-class.html#to_json" title="Returns a JSON representation of the HttpRequest." alt="" coords="17,119,677,139"/>
<area shape="rect" id="node1_11" href="googleapiclient.http.HttpRequest-class.html#from_json" title="Returns an HttpRequest populated with info from a JSON object." alt="" coords="17,139,677,159"/>
<area shape="rect" id="node1" href="googleapiclient.http.HttpRequest-class.html" title="Encapsulates a single HTTP request." alt="" coords="5,5,689,165"/>
</map>
  <img src="uml_class_diagram_for_googleap_22.gif" alt='' usemap="#uml_class_diagram_for_googleap_22" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<pre class="literalblock">
Encapsulates a single HTTP request.

</pre>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">http</span>,
        <span class="summary-sig-arg">postproc</span>,
        <span class="summary-sig-arg">uri</span>,
        <span class="summary-sig-arg">method</span>=<span class="summary-sig-default">'GET'</span>,
        <span class="summary-sig-arg">body</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">headers</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">methodId</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">resumable</span>=<span class="summary-sig-default">None</span>)</span><br />
      Constructor for an HttpRequest.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#execute" class="summary-sig-name">execute</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br />
      Execute the request.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.execute">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#add_response_callback" class="summary-sig-name">add_response_callback</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">cb</span>)</span><br />
      add_response_headers_callback</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.add_response_callback">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#next_chunk" class="summary-sig-name">next_chunk</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br />
      Execute the next step of a resumable upload.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.next_chunk">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#_process_response" class="summary-sig-name" onclick="show_private();">_process_response</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">resp</span>,
        <span class="summary-sig-arg">content</span>)</span><br />
      Process the response from a single chunk upload.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest._process_response">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="to_json"></a><span class="summary-sig-name">to_json</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Returns a JSON representation of the HttpRequest.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.to_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== STATIC METHODS ==================== -->
<a name="section-StaticMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Static Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-StaticMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="from_json"></a><span class="summary-sig-name">from_json</span>(<span class="summary-sig-arg">s</span>,
        <span class="summary-sig-arg">http</span>,
        <span class="summary-sig-arg">postproc</span>)</span><br />
      Returns an HttpRequest populated with info from a JSON object.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.from_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">http</span>,
        <span class="sig-arg">postproc</span>,
        <span class="sig-arg">uri</span>,
        <span class="sig-arg">method</span>=<span class="sig-default">'GET'</span>,
        <span class="sig-arg">body</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">headers</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">methodId</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">resumable</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Constructor for an HttpRequest.

Args:
  http: httplib2.Http, the transport object to use to make a request
  postproc: callable, called on the HTTP response and content to transform
            it into a data object before returning, or raising an exception
            on an error.
  uri: string, the absolute URI to send the request to
  method: string, the HTTP method to use
  body: string, the request body of the HTTP request,
  headers: dict, the HTTP request headers
  methodId: string, a unique identifier for the API method being called.
  resumable: MediaUpload, None if this is not a resumbale request.

</pre>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@util.positional(4)</code></li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="execute"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">execute</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">http</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.execute">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Execute the request.

Args:
  http: httplib2.Http, an http object to be used in place of the
        one the HttpRequest request object was constructed with.
  num_retries: Integer, number of times to retry 500's with randomized
        exponential backoff. If all retries fail, the raised HttpError
        represents the last request. If zero (default), we attempt the
        request only once.

Returns:
  A deserialized object model of the response body as determined
  by the postproc.

Raises:
  googleapiclient.errors.HttpError if the response was not a 2xx.
  httplib2.HttpLib2Error if a transport error has occured.

</pre>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@util.positional(1)</code></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="add_response_callback"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">add_response_callback</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">cb</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.add_response_callback">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
add_response_headers_callback

Args:
  cb: Callback to be called on receiving the response headers, of signature:

  def cb(resp):
    # Where resp is an instance of httplib2.Response

</pre>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@util.positional(2)</code></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="next_chunk"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">next_chunk</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">http</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.next_chunk">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Execute the next step of a resumable upload.

Can only be used if the method being executed supports media uploads and
the MediaUpload object passed in was flagged as using resumable upload.

Example:

  media = MediaFileUpload('cow.png', mimetype='image/png',
                          chunksize=1000, resumable=True)
  request = farm.animals().insert(
      id='cow',
      name='cow.png',
      media_body=media)

  response = None
  while response is None:
    status, response = request.next_chunk()
    if status:
      print &quot;Upload %d%% complete.&quot; % int(status.progress() * 100)


Args:
  http: httplib2.Http, an http object to be used in place of the
        one the HttpRequest request object was constructed with.
  num_retries: Integer, number of times to retry 500's with randomized
        exponential backoff. If all retries fail, the raised HttpError
        represents the last request. If zero (default), we attempt the
        request only once.

Returns:
  (status, body): (ResumableMediaStatus, object)
     The body will be None until the resumable media is fully uploaded.

Raises:
  googleapiclient.errors.HttpError if the response was not a 2xx.
  httplib2.HttpLib2Error if a transport error has occured.

</pre>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@util.positional(1)</code></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="_process_response"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_process_response</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">resp</span>,
        <span class="sig-arg">content</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest._process_response">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Process the response from a single chunk upload.

Args:
  resp: httplib2.Response, the response object.
  content: string, the content of the response.

Returns:
  (status, body): (ResumableMediaStatus, object)
     The body will be None until the resumable media is fully uploaded.

Raises:
  googleapiclient.errors.HttpError if the response was not a 2xx or a 308.

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Tue Mar 10 23:27:50 2015
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
